﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WoWArmoryParser
{
    public class Reputation
    {
        protected int _value;
        #region Properties
        public string Key { get; set; }
        public string Name { get; set; }
        public int Value
        {
            get { return _value; }
            set { _value = value; Status = GetRepEnum( Value ); }
        }
        public ReputationEnum Status { get; protected set; }
        public int RelativeValue
        {
            get
            {
                int res = 0;
                switch (Status)
                {
                    case ReputationEnum.Hated:
                        res = Value + 42000;
                        break;
                    case ReputationEnum.Hostile:
                        res = Value + 6000;
                        break;
                    case ReputationEnum.Unfriendly:
                        res = Value + 3000;
                        break;
                    case ReputationEnum.Neutral:
                        res = Value;
                        break;
                    case ReputationEnum.Friendly:
                        res = Value - 3000;
                        break;
                    case ReputationEnum.Honored:
                        res = Value - 6000;
                        break;
                    case ReputationEnum.Revered:
                        res = Value - 21000;
                        break;
                    case ReputationEnum.Exalted:
                        res = Value - 42000;
                        break;
                }
                return res;
            }
        }
        public int RelativeMax
        {
            get
            {
                int res = 0;
                switch( Status )
                {
                    case ReputationEnum.Hated:
                        res = 36000;
                        break;
                    case ReputationEnum.Hostile:
                        res = 3000;
                        break;
                    case ReputationEnum.Unfriendly:
                        res = 3000;
                        break;
                    case ReputationEnum.Neutral:
                        res = 3000;
                        break;
                    case ReputationEnum.Friendly:
                        res = 6000;
                        break;
                    case ReputationEnum.Honored:
                        res = 12000;
                        break;
                    case ReputationEnum.Revered:
                        res = 21000;
                        break;
                    case ReputationEnum.Exalted:
                        res = 1000;
                        break;
                }
                return res;
            }
        }
        public double RelativeRation
        {
            get { return ( RelativeValue / RelativeMax ); }
        }
        #endregion

        public override string ToString()
        {
 	        return Enum.GetName( typeof( ReputationEnum ), Status );
        }

        protected ReputationEnum GetRepEnum(int _value)
        {
            ReputationEnum res;
            if( _value < -6000 )
            {
                res = ReputationEnum.Hated;
            }
            else if( _value >= -6000 && _value < -3000 )
            {
                res = ReputationEnum.Hostile;
            }
            else if( _value >= 3000 && _value < 0 )
            {
                res = ReputationEnum.Unfriendly;
            }
            else if( _value >= 0 && _value <= 3000 )
            {
                res = ReputationEnum.Neutral;
            }
            else if( _value > 3000 && _value <= 9000 )
            {
                res = ReputationEnum.Friendly;
            }
            else if( _value > 9000 && _value <= 21000 )
            {
                res = ReputationEnum.Honored;
            }
            else if( _value > 21000 && _value <= 42000 )
            {
                res = ReputationEnum.Revered;
            }
            else if( _value > 42000 )
            {
                res = ReputationEnum.Exalted;
            }
            else
            {
                res = ReputationEnum.Neutral;
            }
            return res;
        }
    }

    //public class ReputationList
    //{
    //    protected ReputationList() { }


    //}
}
